package cn.itsource.org.domain;

import cn.itsource.basic.domain.BaseDomain;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "t_department")
public class Department extends BaseDomain {


    //部门编号
    private String sn;
    //部门名称
    private String name;
    //部门路径
    @Column(name = "dir_Path")
    private String dirPath;
    //部门状态：1启用,0禁用
    private Integer state = 1;
    //部门经理ID
    @Column(name = "manager_id")
    private Long managerId;
    //上级部门ID
    @Column(name = "parent_id")
    private Long parentId;

    @Transient   //临时字段 不参与表的增删改
    private String managerName;    //部门经理
    @Transient
    private String parentName;      //上级部门

    @Transient
    private Long[] parentIds;     //接收前端部门数组的数据

    @Transient   //临时字段 不参与表的增删改
    @JsonInclude(JsonInclude.Include.NON_EMPTY)            //如果当前属性集合数据为空,那就用null代替
    private List<Department> children = new ArrayList<>();

}
